/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id: buf.h 348 2010-11-29 09:01:16Z bgao $ 
#
# $Author: bgao $ 
#
# $Revision: 348 $ 
#
# $Date: 2010-11-29 17:01:16 +0800 (星期一, 29 十一月 2010) $ 
#
# Description: 
#
=============================================================================*/
/*! @file buf.h
 *  @brief This is the interface for buf module.
 */
#ifndef _BUF_H_
#define _BUF_H_

#include "mem.h"

/*! the number of buffer blocks in the buf pool */
#define BUF_SIZE 10

/*! the base buf type */
typedef struct _buf_t {
    struct _but_t *next;   /*!< pointer to the next buf in the list. */
    uint8 length;          /*!< the length of the valid byte pointed by ptr. */
    uint8 *ptr;            /*!< the first valid byte pointed by ptr. */
    uint8 array[127 + 1];  /*!< the memory location to store the bytes. */
} buf_t;

int8 buf_init(void);
buf_t *buf_alloc(bool is_trx);
/*! note that user should set the buf pointr to NULL, after free. */
int8 buf_free(buf_t *buf);

#endif /* _BUF_H_ */
